<?php
/**
 *
 * @authors generator
 * @date    2020-10-16 11:29:50
 */

namespace App\Commons\Domain\Module\Financial\Model;

use App\Commons\Domain\Casts\CdnUrl;
use App\Commons\Domain\Core\Model;
use App\Commons\Domain\Module\Exchange\Model\AdPayment;
use App\Commons\Domain\Module\UserCenter\Model\Account;
use App\Commons\Domain\Module\UserCenter\Model\Member;
use App\Commons\Domain\Traits\Common\GenderTextTrait;
use App\Commons\Domain\Traits\MobileMask\MobileMask;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Tymon\JWTAuth\Contracts\JWTSubject;


/**
 * App\Commons\Domain\Module\Financial\Model\Payment
 *
 * @property int $id
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 * @property string $uid
 * @property int $type 收款方式：1银行卡、2支付宝、3微信
 * @property string $bank_name 开户银行
 * @property string $bank_branch 开户支行(选填)
 * @property mixed $qr_code 支付宝/微信二维码地址
 * @property string $account 收款账户：银行卡号、支付宝账号、微信账号
 * @property int $status 状态：0开启，1关闭
 * @property string|null $deleted_at 是否删除，有值为删除
 * @property-read Member $member
 * @method static \Illuminate\Database\Eloquent\Builder|Payment newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Payment newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Payment query()
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereAccount($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereBankBranch($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereBankName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereQrCode($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereUid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Payment whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class Payment extends Model
{

    protected $casts = [
//        'qr_code' => CdnUrl::class . ':image'
    ];

    public function getQrCodeAttribute($value)
    {
        return env('APP_URL').'/'.$value;
    }

    /**
     * 所属用户
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function member()
    {
        return $this->belongsTo(Member::class, 'uid', 'uid');
    }

    /**
     * 广告-支付方式 关联表
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function adPayment()
    {
        return $this->hasMany(AdPayment::class, 'payment_id', 'id');
    }
}
